#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2021/7/24 10:58
# @Author  : LiShan
# @Email   : lishan_1997@126.com
# @File    : mean_time.py
# @Note    : this is note
import numpy as np


# 无加速
with open("no_interface_no_accelerate.txt", "r") as f:
    t = f.read().split("\n")
tt = []
for i in range(1, len(t)):
    if t[i] != "":
        tt.append(float(t[i]))
print(tt)
a = round(float(np.mean(tt)), 2)
print("无界面，无加速", a)

# 关闭图形加速
with open("no_interface_yes_accelerate1.txt", "r") as f:
    t = f.read().split("\n")
tt = []
for i in range(1, len(t)):
    if t[i] != "":
        tt.append(float(t[i]))
print(tt)
b1 = round(float(np.mean(tt)), 2)
print("无界面，关闭图形加速", b1)


# 降低分辨率加速
with open("no_interface_yes_accelerate2.txt", "r") as f:
    t = f.read().split("\n")
tt = []
for i in range(1, len(t)):
    if t[i] != "":
        tt.append(float(t[i]))
print(tt)
b2 = round(float(np.mean(tt)), 2)
print("无界面，降低分辨率加速", b2)


# 电源模式加速
with open("no_interface_yes_accelerate3.txt", "r") as f:
    t = f.read().split("\n")
tt = []
for i in range(1, len(t)):
    if t[i] != "":
        tt.append(float(t[i]))
print(tt)
b3 = round(float(np.mean(tt)), 2)
print("无界面，电源模式加速", b3)

# GPU加速
with open("no_interface_yes_accelerate4.txt", "r") as f:
    t = f.read().split("\n")
tt = []
for i in range(1, len(t)):
    if t[i] != "":
        tt.append(float(t[i]))
print(tt)
b4 = round(float(np.mean(tt)), 2)
print("无界面，GPU加速", b4)

# GPU加速
with open("yes_interface_yes_accelerate.txt", "r") as f:
    t = f.read().split("\n")
tt = []
for i in range(1, len(t)):
    if t[i] != "":
        tt.append(float(t[i]))
print(tt)
c = round(float(np.mean(tt)), 2)
print("有界面，所有加速", c)



print("无界面情况下加速1提升%.2f%%" % (round((a-b1)/a*100, 2)))
print("无界面情况下加速2提升%.2f%%" % (round((a-b2)/a*100, 2)))
print("无界面情况下加速3提升%.2f%%" % (round((a-b3)/a*100, 2)))
print("无界面情况下加速4提升%.2f%%" % (round((a-b4)/a*100, 2)))
print("有界面情况下提升%.2f%%" % (round((a-c)/a*100, 2)))
